package contracts.organization

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer("/api/organizations/users/\\d+"),
                producer("/api/organizations/users/1"))
        headers {
            contentType(applicationJsonUtf8())
        }
    }
    response {
        status 200
        body("""
          [{
              "id": 1,
              "title": "思沃训练营",
              "createTime": "2018-11-09"
          }]
        """)
        bodyMatchers {
            jsonPath('$.[*]', byType())
            jsonPath('$.[*].id', byRegex(number()))
            jsonPath('$.[*].title', byType())
            jsonPath('$.[*].createTime', byType())
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
